//
//  SleepHRVView.swift
//  DaRings
//
//  Created by 易先生 on 2022/11/3.
//

import UIKit
import MYModule

open class HeartRateSubDataView: View {
    
    open override func makeUI() {
        super.makeUI()
        
        self.addSubview(iconImageView)
        self.addSubview(hrvStackView)
        self.addSubview(descLabel)
        
        hrvStackView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.centerX.equalToSuperview()
        }
        
        iconImageView.snp.makeConstraints { make in
            make.trailing.equalTo(hrvStackView.snp.leading)
            make.centerY.equalTo(hrvStackView)
        }
        
        descLabel.snp.makeConstraints { make in
            make.top.equalTo(hrvStackView.snp.bottom)
            make.centerX.equalTo(hrvStackView).offset(-10)
            make.bottom.equalToSuperview()
        }
    }
    
    public func setConfig(icon: String,
                          hrv:String,
                          until: String,
                          textColor: UIColor,
                          desc: String) {
        iconImageView.image = UIImage(named: icon)
        dataLabel.text = hrv
        unitLabel.text = until
        descLabel.text = desc
        
    }
    
    private lazy var hrvStackView: StackView = {
        let hrvStackView = StackView()
        hrvStackView.alignment = .firstBaseline
        hrvStackView.spacing = 2
        hrvStackView.axis = .horizontal
        hrvStackView.distribution = .fill
        hrvStackView.addArrangedSubview(dataLabel)
        hrvStackView.addArrangedSubview(unitLabel)
        return hrvStackView
    }()
    
    public lazy var iconImageView: ImageView = {
        let iconImageView = ImageView()
        return iconImageView
    }()
    
    public lazy var dataLabel: Label = {
        let hrvLabel = Label()
        hrvLabel.textColor = UIColor.assist_222222
        hrvLabel.font = Fonts.boldSystemFont(ofSize: 22)
        return hrvLabel
    }()

    public lazy var unitLabel: Label = {
        let unitLabel = Label()
        unitLabel.font = Fonts.systemFont(ofSize: 12)
        unitLabel.textColor = UIColor.assist_222222
        return unitLabel
    }()
    
    public lazy var descLabel: Label = {
        let descLabel = Label()
        descLabel.font = Fonts.systemFont(ofSize: 12)
        descLabel.textColor = UIColor.assist_222222
        return descLabel
    }()
}
